﻿using DevExpress.Xpo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Model.View
{
    [Persistent("vStockSummary")]
    public class StockSummary : XPLiteObject
    {
        public StockSummary(Session session) : base(session) { }
        public override void AfterConstruction()
        {
            base.AfterConstruction();
        }
        P_Product fProductID;
        /// <summary>
        /// 货品
        /// </summary>
        public P_Product ProductID
        {
            get { return fProductID; }
            set { SetPropertyValue<P_Product>("ProductID", ref fProductID, value); }
        }
        decimal fQuantity;
        /// <summary>
        /// 数量
        /// </summary>
        [DbType("decimal(18,2)")]
        public decimal Quantity
        {
            get { return fQuantity; }
            set { SetPropertyValue<decimal>("Quantity", ref fQuantity, value); }
        }
    }

    public class StockSummaryView 
    {
        public StockSummaryView(XPView view) 
        {
            view.Properties.AddRange(new ViewProperty[]{
                new ViewProperty("ProductID.CategoryID.CategoryName",SortDirection.None,"[ProductID.CategoryID.CategoryName]",false,true),
                new ViewProperty("ProductID.BrandID.BrandName",SortDirection.None,"[ProductID.BrandID.BrandName]",false,true),
                new ViewProperty("ProductID.ProductCode",SortDirection.None,"ProductID.ProductCode",false,true),
                new ViewProperty("ProductID.ProductName",SortDirection.None,"ProductID.ProductName",false,true),
                new ViewProperty("ProductID.ProductSpec",SortDirection.None,"ProductID.ProductSpec",false,true),
                new ViewProperty("ProductID.Unit",SortDirection.None,"ProductID.Unit",false,true),
                new ViewProperty("Quantity",SortDirection.None,"[Quantity]",false,true),
            });
        }
    }
}
